package validator

import "regexp"

type statusType struct{}

var statusReg = regexp.MustCompile("^[01]$")

func (p *statusType) Validate(name string, val string, required bool) (bool, string) {
	if val == "" {
		if required {
			return false, name + "不能为空"
		}
		return true, ""
	}

	if !statusReg.MatchString(val) {
		return false, name + "应为信息状态枚举"
	}

	return true, ""
}
